<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Support\Facades\Hash;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Common\CodeHandler;
use App\Models\Admin\Admin as User;
use App\Models\Admin\Menu;

class AuthController extends Controller
{
    //获取极限验证码
    public function getGeetest()
    {
        $user = new User;
        $code = $user->getGeetCode();

        return $code;
    }

    public function login(Request $request)
    {
        $user = new User;
        $data = $user->login($request);

        return $data;
    }

    public function userInfo(Request $request)
    {
        $user = new User;
        $data = $user->getInfo();

        return $data;
    }

    public function getUserMenu(Request $request)
    {
        $menu = new Menu;
        $arr = $menu->getUserMenuNode();

        return $arr;
    }

    public function getList(Request $request)
    {
        $pageSize = $request['pageSize'];

        $user = new User;
        $data = $user->getList($pageSize);

        return $data;
    }

    public function getRole()
    {
        $roles = new Role;
        $data = $roles->getAllRole();

        return $data;
    }

    public function handle(Request $request)
    {
        $user = new User;
        $res = $user->handle($request);

        return $res;
    }

    public function delete(Request $request)
    {
        $id = $request['id'];
        $adminModel = new User;
        $result = $adminModel->deleteAction($id);

        return $result;
    }
}
